package ma.xin.shi.configurations;

public class ServiceEntryMergeCase {
    // 定义 RpcType 枚举于 ServiceEntry 内部
    public enum RpcType {
        METHOD, EVENT, FIELD
    }

    private String serviceName;
    private int serviceId;
    private RpcType rpcType;

    // Method specific fields
    private String methodName;
    private int methodId;
    private boolean rrFlag;

    // Event specific fields
    private String eventName;
    private int eventId;
    private String eventParameter;

    // Field specific fields
    private String fieldName;
    private String fieldDataType;

    public ServiceEntryMergeCase(String serviceName, int serviceId, RpcType rpcType) {
        this.serviceName = serviceName;
        this.serviceId = serviceId;
        this.rpcType = rpcType;
    }

    // Getters and Setters for common fields
    public String getServiceName() { return serviceName; }
    public void setServiceName(String serviceName) { this.serviceName = serviceName; }

    public int getServiceId() { return serviceId; }
    public void setServiceId(int serviceId) { this.serviceId = serviceId; }

    public RpcType getRpcType() { return rpcType; }
    public void setRpcType(RpcType rpcType) { this.rpcType = rpcType; }

    // Getters and Setters for method specific fields
    public String getMethodName() { return methodName; }
    public void setMethodName(String methodName) { this.methodName = methodName; }

    public int getMethodId() { return methodId; }
    public void setMethodId(int methodId) { this.methodId = methodId; }

    public boolean isRrFlag() { return rrFlag; }
    public void setRrFlag(boolean rrFlag) { this.rrFlag = rrFlag; }

    // Getters and Setters for event specific fields
    public String getEventName() { return eventName; }
    public void setEventName(String eventName) { this.eventName = eventName; }

    public int getEventId() { return eventId; }
    public void setEventId(int eventId) { this.eventId = eventId; }

    public String getEventParameter() { return eventParameter; }
    public void setEventParameter(String eventParameter) { this.eventParameter = eventParameter; }

    // Getters and Setters for field specific fields
    public String getFieldName() { return fieldName; }
    public void setFieldName(String fieldName) { this.fieldName = fieldName; }

    public String getFieldDataType() { return fieldDataType; }
    public void setFieldDataType(String fieldDataType) { this.fieldDataType = fieldDataType; }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("ServiceEntry{");
        sb.append("serviceName='").append(serviceName).append('\'');
        sb.append(", serviceId=").append(serviceId);
        sb.append(", rpcType=").append(rpcType);

        switch (rpcType) {
            case METHOD:
                sb.append(", methodName='").append(methodName).append('\'');
                sb.append(", methodId=").append(methodId);
                sb.append(", rrFlag=").append(rrFlag);
                break;
            case EVENT:
                sb.append(", eventName='").append(eventName).append('\'');
                sb.append(", eventId=").append(eventId);
                sb.append(", eventParameter='").append(eventParameter).append('\'');
                break;
            case FIELD:
                sb.append(", fieldName='").append(fieldName).append('\'');
                sb.append(", fieldDataType='").append(fieldDataType).append('\'');
                break;
        }

        sb.append('}');
        return sb.toString();
    }
}
